//
//  NRWTabelViewCollectionCell.m
//  NRWMall
//
//  Created by 邢毅 on 2018/6/19.
//  Copyright © 2018年 com.anpxd. All rights reserved.
//

#import "NRWTabelViewCollectionCell.h"

@implementation NRWTabelViewCollectionCell
{
    UILabel *_mTitleLabel;
    UILabel *_mDetailLabel;
    UIImageView *_mImageView;
}

- (void)setTitleString:(NSString *)titleString {
    
    _titleString = titleString;
    
    _mTitleLabel.text = titleString;
}

- (void)setDetailString:(NSString *)detailString {
    
    _detailString = detailString;
    
    _mDetailLabel.text = detailString;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = self.contentView.backgroundColor = [UIColor whiteColor];
        self.backgroundView.opaque = self.contentView.opaque = YES;
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    _mTitleLabel = [[UILabel alloc] init];
    _mTitleLabel.font = getThemeFont(15);
    _mTitleLabel.textColor = mainFontColor();
    _mTitleLabel.backgroundColor = [UIColor whiteColor];
    _mTitleLabel.opaque = YES;
    
    _mDetailLabel = [[UILabel alloc] init];
    _mDetailLabel.font = getThemeFont(13);
    _mDetailLabel.textColor = mainColor();
    _mDetailLabel.backgroundColor = [UIColor whiteColor];
    _mDetailLabel.textAlignment = NSTextAlignmentRight;
    _mDetailLabel.opaque = YES;
    
    _mImageView = [[UIImageView alloc] init];
    _mImageView.image = getImage(@"icon_arrow");
    _mImageView.backgroundColor = [UIColor whiteColor];
    _mImageView.opaque = YES;
    
    [self.contentView addSubview:_mTitleLabel];
    [self.contentView addSubview:_mDetailLabel];
    [self.contentView addSubview:_mImageView];
    
    [_mTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(17);
        make.top.bottom.equalTo(self.contentView);
    }];
    
    [_mDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self->_mImageView.mas_right).offset(-10);
        make.top.bottom.equalTo(self.contentView);
        make.left.lessThanOrEqualTo(self->_mTitleLabel.mas_right).offset(5);
    }];
    
    [_mImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.right.equalTo(self.contentView.mas_right).offset(-12);
    }];
    
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = getColor(@"#E9E9E9");
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.equalTo(self.contentView);
        make.height.equalTo(@0.5);
    }];
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    _mTitleLabel.frame = CGRectMake(17, 0, 100, self.viewHeight);
}

@end
